home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / ItemEvent.java < prev    next >
Text File  |  1998-09-22  |  3KB  |  128 lines

  1. /*
  2.  * @(#)ItemEvent.java    1.14 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.event;
  16.  
  17. import java.awt.Component;
  18. import java.awt.AWTEvent;
  19. import java.awt.Event;
  20. import java.awt.ItemSelectable;
  21.  
  22. /**
  23.  * The item event emitted by ItemSelectable objects.
  24.  * This event is generated when an item is selected or de-selected.
  25.  * @see java.awt.ItemSelectable
  26.  * @see ItemListener
  27.  *
  28.  * @version 1.14 07/01/98
  29.  * @author Carl Quinn
  30.  */
  31. public class ItemEvent extends AWTEvent {
  32.  
  33.     /**
  34.      * Marks the first integer id for the range of item event ids.
  35.      */
  36.     public static final int ITEM_FIRST        = 701;
  37.  
  38.     /**
  39.      * Marks the last integer id for the range of item event ids.
  40.      */
  41.     public static final int ITEM_LAST        = 701;
  42.  
  43.     /** 
  44.      * The item state changed event type.
  45.      */
  46.     public static final int ITEM_STATE_CHANGED    = ITEM_FIRST; //Event.LIST_SELECT 
  47.  
  48.     /**
  49.      * The item selected state change type.
  50.      */
  51.     public static final int SELECTED = 1;
  52.  
  53.     /** 
  54.      * The item de-selected state change type.
  55.      */
  56.     public static final int DESELECTED    = 2;
  57.  
  58.     Object item;
  59.     int stateChange;
  60.  
  61.     /*
  62.      * JDK 1.1 serialVersionUID 
  63.      */
  64.     private static final long serialVersionUID = -608708132447206933L;
  65.  
  66.     /**
  67.      * Constructs a ItemSelectEvent object with the specified ItemSelectable source,
  68.      * type, item, and item select state.
  69.      * @param source the ItemSelectable object where the event originated
  70.      * @id the event type
  71.      * @item the item where the event occurred
  72.      * @stateChange the state change type which caused the event
  73.      */
  74.     public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
  75.         super(source, id);
  76.     this.item = item;
  77.         this.stateChange = stateChange;
  78.     }
  79.  
  80.     /**
  81.      * Returns the ItemSelectable object where this event originated.
  82.      */
  83.     public ItemSelectable getItemSelectable() {
  84.         return (ItemSelectable)source;
  85.     }
  86.  
  87.    /**
  88.     * Returns the item where the event occurred.
  89.     */
  90.     public Object getItem() {
  91.         return item;
  92.     }
  93.  
  94.    /**
  95.     * Returns the state change type which generated the event.
  96.     * @see #SELECTED
  97.     * @see #DESELECTED
  98.     */
  99.     public int getStateChange() {
  100.         return stateChange;
  101.     }
  102.  
  103.     public String paramString() {
  104.         String typeStr;
  105.         switch(id) {
  106.           case ITEM_STATE_CHANGED:
  107.               typeStr = "ITEM_STATE_CHANGED";
  108.               break;
  109.           default:
  110.               typeStr = "unknown type";
  111.         }
  112.  
  113.         String stateStr;
  114.         switch(stateChange) {
  115.           case SELECTED:
  116.               stateStr = "SELECTED";
  117.               break;
  118.           case DESELECTED:
  119.               stateStr = "DESELECTED";
  120.               break;
  121.           default:
  122.               stateStr = "unknown type";
  123.         }
  124.         return typeStr + ",item="+item + ",stateChange="+stateStr;
  125.     }
  126.  
  127. }
  128.